{layout name="layout" /}

<div class="Hui-article">
    <article class="cl pd-20">
        <form action="" method="post" class="form form-horizontal" id="form-article-add">
            <!-- 文章标题 -->
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">*</span>文章标题：</label>
                <div class="formControls col-xs-6 col-sm-4">
                    <input type="text" class="input-text" value="" placeholder="文章标题,不超过100个字符" id="title" name="title">
                </div>
                <div class="formControls col-xs-2 col-sm-2">
                    <span class="title" style="color:red"></span>
                </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">&nbsp;作&nbsp;&nbsp;者&nbsp;：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" class="input-text" value="" placeholder="不填写则为当前登陆账号" id="writer" name="writer">
                </div>
                <label class="form-label col-xs-4 col-sm-2">文章来源：</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" class="input-text" value="" placeholder="不填写则为默认网络" id="source" name="source">
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">&nbsp;关键字&nbsp;：</label>
                <div class="formControls col-xs-8 col-sm-6">
                    <input type="text" class="input-text" value="" placeholder="多个关键字用英文半角逗号(,)隔开" id="keywords" name="keywords">
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">摘要：</label>
                <div class="formControls col-xs-8 col-sm-6">
                    <textarea id="summary" name="summary" cols="" rows="" class="textarea" placeholder="说点什么...最多输入1000个字符"
                        datatype="*10-100" dragonfly="true" nullmsg="备注不能为空！" onKeyUp="textarealength(this,1000)"></textarea>
                    <p class="textarea-numberbar">
                        <em class="textarea-length">0</em>/1000</p>
                </div>
                <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">
                    <span class="c-red">* </span>文章内容：</label>
                    <div class="formControls col-xs-8 col-sm-8">
                        <script id="editor" type="text/plain" style="width:100%;height:400px;"></script>
                    </div>
                    <div class="col-3"> </div>
            </div>
            <div class="row cl">
                <label class="form-label col-xs-4 col-sm-2">排序</label>
                <div class="formControls col-xs-10 col-sm-10 col-md-8">
                    <input type="text" class="input-text" value="" name="sort" style="width:60px;">
                    <span class="c-red">* 数值越小,排序越靠前</span>
                </div>
                <!-- <label class="form-label col-xs-4 col-sm-2">点击量</label>
                <div class="formControls col-xs-8 col-sm-2">
                    <input type="text" class="input-text" value="" name="clicks" style="width:60px;">
                </div>
                <div class="col-3"> </div> -->
            </div>
            <div class="row cl">
                <div class="col-xs-8 col-sm-9 col-xs-offset-4 col-sm-offset-3">
                    <button class="btn btn-primary radius" type="submit">
                        <i class="Hui-iconfont">&#xe632;</i> 保存提交</button>
                    <button type="button" class="btn btn-default radius" onClick="window.history.back();">&nbsp;&nbsp;取消&nbsp;&nbsp;</button>
                </div>
            </div>
        </form>
    </article>
</div>


<!--请在下方写此页面业务相关的脚本-->
<script type="text/javascript" src="/static/h-ui/lib/ueditor/1.4.3/ueditor.config.js"></script>
<script type="text/javascript" src="/static/h-ui/lib/ueditor/1.4.3/ueditor.all.min.js"></script>
<script type="text/javascript" src="/static/h-ui/lib/ueditor/1.4.3/lang/zh-cn/zh-cn.js"></script>
<script type="text/javascript">
    $(function () {
        //实例化编辑器   
        var ue = UE.getEditor('editor');

        //提交表单
        $("#form-article-add").submit(function () {
            var note = $("#summary").val();

            if (!$("#title").val()) {
                layer.msg('标题不能为空!', {
                    icon: 5,
                    time: 1000
                });
                return false;
            }

            if (getblen(note) > 1000) {
                layer.msg('摘要过长', {
                    icon: 5,
                    time: 1000
                });
                return false;
            }
        })
    });

    $("#title").blur(function(){
        $.post('testtitle', {
            'title': $("#title").val()
        }, function (data) {
            if (data.code == 2) {
                layer.msg("标题已存在, 请另拟标题!", {
                    icon: 1,
                    time: 1000
                });
                $('span.title').html("注意, 标题重复!");
            }
        }, 'json');
    });
</script>
<!--请在上方写此页面业务相关的脚本-->

</body>

</html>